home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWWindow / Sources / FWWindow.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  35.8 KB  |  1,242 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWWindow.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifdef FW_PRECOMPILE_BY_LAYER
  11. #include "FWOS.hpp"
  12. #endif
  13.  
  14. #ifdef FW_PRECOMPILE_BY_SUBSYSTEM
  15. #include "FWWindow.hpp"
  16. #endif
  17.  
  18.  
  19. #ifndef FWWINDOW_H
  20. #include "FWWindow.h"
  21. #endif
  22.  
  23. // ----- OS Layer -----
  24.  
  25. #ifndef FWMEMORY_H
  26. #include "FWMemory.h"
  27. #endif
  28.  
  29. #ifndef FWRESOUR_H
  30. #include "FWResour.h"
  31. #endif
  32.  
  33. #ifndef FWGRUTIL_H
  34. #include "FWGrUtil.h"
  35. #endif
  36.  
  37. #ifndef FWFCTINF_H
  38. #include "FWFctInf.h"
  39. #endif
  40.  
  41. #ifndef FWWINPRO_H
  42. #include "FWWinPro.h"
  43. #endif
  44.  
  45. #ifndef FWEVENT_H
  46. #include "FWEvent.h"
  47. #endif
  48.  
  49. #ifndef FWGDEV_H
  50. #include "FWGDev.h"
  51. #endif
  52.  
  53. #ifndef FWACQUIR_H
  54. #include "FWAcquir.h"
  55. #endif
  56.  
  57. #if defined(FW_BUILD_MAC) && !defined(FWMACOS_H)
  58. #include "FWMacOS.h"
  59. #endif
  60.  
  61. // ----- Foundation Layer -----
  62.  
  63. #ifndef FWBNDSTR_H
  64. #include "FWBndStr.h"
  65. #endif
  66.  
  67. // ----- OpenDoc Includes -----
  68.  
  69. #ifndef SOM_ODWindow_xh
  70. #include <Window.xh>
  71. #endif
  72.  
  73. #ifndef SOM_ODStorageUnit_xh
  74. #include <StorageU.xh>
  75. #endif
  76.  
  77. #ifndef SOM_ODDraft_xh
  78. #include <Draft.xh>
  79. #endif
  80.  
  81. #ifndef SOM_ODPart_xh
  82. #include <Part.xh>
  83. #endif
  84.  
  85. #ifndef SOM_ODFrame_xh
  86. #include <Frame.xh>
  87. #endif
  88.  
  89. #ifndef SOM_ODSession_xh
  90. #include <ODSessn.xh>
  91. #endif
  92.  
  93. #ifndef SOM_ODInfo_xh
  94. #include <Info.xh>
  95. #endif
  96.  
  97. #ifndef SOM_ODWindowState_xh
  98. #include <WinStat.xh>
  99. #endif
  100.  
  101. #ifndef SOM_ODFacet_xh
  102. #include <Facet.xh>
  103. #endif
  104.  
  105. #ifndef SOM_ODShape_xh
  106. #include <Shape.xh>
  107. #endif
  108.  
  109. #if defined(FW_BUILD_MAC) & !defined(__RESOURCES__)
  110. #include <Resources.h>
  111. #endif
  112.  
  113. #ifndef FWODMISS_H
  114. #include "FWODMiss.h"
  115. #endif
  116.  
  117. //========================================================================================
  118. //    Runtime Info
  119. //========================================================================================
  120.  
  121. #if FW_LIB_EXPORT_PRAGMAS
  122. #pragma lib_export on
  123. #endif
  124.  
  125. #ifdef FW_BUILD_MAC
  126. #pragma segment fwwindow
  127. #endif
  128.  
  129. FW_DEFINE_CLASS_M0(FW_CWindow)
  130.  
  131. //========================================================================================
  132. //    defines
  133. //========================================================================================
  134.  
  135. #ifdef FW_BUILD_MAC
  136. #define FW_kSystem75WindoidWDEF        1984            //     System 7.5 windoid 
  137. #define FW_kNonSystem75WindoidWDEF    48                //     System 7.5 windoid (for system < 7.5)
  138. #define FW_kSystem75ToggleTBar        1                //    Bit 0 tell us whether to hilite/unhilite the tittle bar
  139. #define FW_kSystem75HasGrow            2                //    Bit 1 is the grow bit
  140. #define FW_kSystem75HasZoom            4                //    Bit 2 is the zoom bit
  141. #define FW_kSystem75VertTBar        8                //    bit 3 is for a vertical tittle bar
  142. #endif
  143.  
  144. //========================================================================================
  145. //    Static Members
  146. //========================================================================================
  147.  
  148. #ifdef FW_BUILD_MAC
  149. Handle FW_CWindow::gMacFloatWindowProc = NULL;
  150. #endif
  151.  
  152. //========================================================================================
  153. // CLASS FW_CWindow
  154. //========================================================================================
  155.  
  156. //----------------------------------------------------------------------------------------
  157. // FW_CWindow::FW_CWindow
  158. //----------------------------------------------------------------------------------------
  159.  
  160. FW_CWindow::FW_CWindow(Environment* ev, 
  161.                         ODPart* thePart,
  162.                         ODTypeToken viewType,
  163.                         ODTypeToken presentation,
  164.                         const FW_CPoint& interiorSize,
  165.                         const FW_CPoint& position,
  166.                         WindowStyle style) :
  167.     fGraphicDevice(NULL),
  168.     fSession(thePart->GetStorageUnit(ev)->GetSession(ev)),
  169.     fWindowID(kODNULLID)
  170. {    
  171.     FW_CString32 windowTitle("");    // the title doesn't matter
  172.         
  173.     PrivCreateODWindow(ev, 
  174.                     thePart, NULL, 
  175.                     TRUE, viewType,
  176.                     presentation, windowTitle, 
  177.                     interiorSize, position,
  178.                     style);
  179. }
  180.  
  181. //----------------------------------------------------------------------------------------
  182. // FW_CWindow::FW_CWindow
  183. //----------------------------------------------------------------------------------------
  184.  
  185. FW_CWindow::FW_CWindow(Environment* ev, 
  186.                         ODPart* thePart,
  187.                         ODFrame* parentFrame,
  188.                         FW_Boolean    persistent,
  189.                         ODTypeToken viewType,
  190.                         ODTypeToken presentation,
  191.                         const FW_CString& windowTitle,
  192.                         const FW_CPoint& interiorSize,
  193.                         const FW_CPoint& position,
  194.                         WindowStyle style) :
  195.     fGraphicDevice(NULL),
  196.     fSession(thePart->GetStorageUnit(ev)->GetSession(ev)),
  197.     fWindowID(kODNULLID)
  198. {
  199.     PrivCreateODWindow(ev, 
  200.                     thePart, parentFrame, 
  201.                     persistent, viewType,
  202.                     presentation, windowTitle, 
  203.                     interiorSize, position,
  204.                     style);
  205. }
  206.  
  207. //----------------------------------------------------------------------------------------
  208. // FW_CWindow::FW_CWindow
  209. //----------------------------------------------------------------------------------------
  210.  
  211. FW_CWindow::FW_CWindow(Environment* ev, 
  212.                         ODPart* thePart,
  213.                         ODFrame* odFrame) :
  214.     fGraphicDevice(NULL),
  215.     fSession(thePart->GetStorageUnit(ev)->GetSession(ev)),
  216.     fWindowID(kODNULLID)
  217. {
  218.     PrivCreateODWindowForFrame(ev, thePart, odFrame);
  219. }
  220.  
  221. //----------------------------------------------------------------------------------------
  222. // FW_CWindow::FW_CWindow
  223. //----------------------------------------------------------------------------------------
  224.  
  225. FW_CWindow::FW_CWindow(Environment* ev, ODPart* thePart, ODID windowID) :
  226.     fGraphicDevice(NULL),
  227.     fSession(thePart->GetStorageUnit(ev)->GetSession(ev)),
  228.     fWindowID(windowID)
  229. {
  230. }
  231.  
  232. //----------------------------------------------------------------------------------------
  233. // FW_CWindow::~FW_CWindow
  234. //----------------------------------------------------------------------------------------
  235.  
  236. FW_CWindow::~FW_CWindow()
  237. {
  238.     if (fGraphicDevice)
  239.         fGraphicDevice->Release();
  240. }
  241.  
  242. //----------------------------------------------------------------------------------------
  243. // FW_CWindow::AcquireODWindow
  244. //----------------------------------------------------------------------------------------
  245.  
  246. ODWindow* FW_CWindow::AcquireODWindow(Environment* ev) const
  247. {
  248.     FW_ASSERT(fWindowID != NULL);
  249.  
  250. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  251.     return fSession->GetWindowState(ev)->AcquireWindow(ev, fWindowID);
  252. #else
  253.     return fSession->GetWindowState(ev)->GetWindow(ev, fWindowID);
  254. #endif
  255. }
  256.  
  257. //----------------------------------------------------------------------------------------
  258. // FW_CWindow::Show
  259. //----------------------------------------------------------------------------------------
  260.  
  261. void FW_CWindow::Show(Environment* ev)
  262. {
  263.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  264.     aqODWindow->Show(ev);
  265.     
  266.     // Because hidden floating window are sent to the back
  267.     if (IsFloating(ev))
  268.         Select(ev);
  269. }
  270.  
  271. //----------------------------------------------------------------------------------------
  272. // FW_CWindow::GetWindowTitle
  273. //----------------------------------------------------------------------------------------
  274.  
  275. void FW_CWindow::GetWindowTitle(Environment* ev, FW_CString& windowTiltle) const
  276. {
  277.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  278.  
  279. #ifdef FW_BUILD_MAC
  280.     Str255 title;
  281.     ::GetWTitle(aqODWindow->GetPlatformWindow(ev), title);
  282.     windowTiltle.ReplaceAll(windowTiltle);
  283. #endif
  284.  
  285. #ifdef FW_BUILD_WIN
  286.     char buffer[256];
  287.     ::GetWindowText(aqODWindow->GetPlatformWindow(ev), buffer, 255);
  288.     windowTiltle.ReplaceAll(buffer);    
  289. #endif
  290. }
  291.  
  292. //----------------------------------------------------------------------------------------
  293. // FW_CWindow::SetWindowTitle
  294. //----------------------------------------------------------------------------------------
  295.  
  296. void FW_CWindow::SetWindowTitle(Environment* ev, const FW_CString& windowTiltle)
  297. {
  298.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  299.  
  300. #ifdef FW_BUILD_MAC
  301.     Str255 title;
  302.     windowTiltle.ExportPascal(title);
  303.     ::SetWTitle(aqODWindow->GetPlatformWindow(ev), title);
  304. #endif
  305.  
  306. #ifdef FW_BUILD_WIN
  307.     ::SetWindowText(aqODWindow->GetPlatformWindow(ev), windowTiltle);
  308. #endif
  309. }
  310.  
  311. //----------------------------------------------------------------------------------------
  312. // FW_CWindow::HideShowOnActivate
  313. //----------------------------------------------------------------------------------------
  314.  
  315. void FW_CWindow::HideShowOnActivate(Environment* ev, FW_Boolean state)
  316. {
  317. FW_UNUSED(state);
  318.     // Don't do anything
  319. }
  320.  
  321. //---------------------------------------------------------------------------------------
  322. //    FW_CWindow::PrivCreateODWindowForFrame
  323. //---------------------------------------------------------------------------------------
  324.  
  325. void FW_CWindow::PrivCreateODWindowForFrame(Environment* ev, 
  326.                                         ODPart* odPart,
  327.                                         ODFrame* odFrame)
  328. {
  329. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR2
  330.  
  331.     FW_ASSERT(fWindowID == kODNULLID);
  332.     
  333.     FW_CWindowProperties props(ev);
  334.     
  335.     FW_Boolean hasWinProp = props.ReadWindowProperties(ev, odFrame);
  336.     
  337.     ODPlatformWindow platformWindow = NULL;
  338.     
  339. #ifdef FW_BUILD_MAC
  340.     FW_CPoint interiorSize(props.fBoundsRect.right - props.fBoundsRect.left, 
  341.                             props.fBoundsRect.bottom - props.fBoundsRect.top);
  342.     FW_CPoint position(props.fBoundsRect.left, props.fBoundsRect.top);
  343.  
  344.     platformWindow = PrivMacCreatePlatformWindow(ev, 
  345.                                             props.fMacTitle, 
  346.                                             interiorSize, 
  347.                                             position,             // ATTENTION: position is the inside position
  348.                                             props.fMacProcID, 
  349.                                             props.fMacHasCloseBox);
  350. #endif
  351.  
  352. #ifdef FW_BUILD_WIN
  353.     FW_DEBUG_MESSAGE("Not Implemented Yet!");
  354. #endif    
  355.     
  356.     ODWindowState* windowState = odPart->GetStorageUnit(ev)->GetSession(ev)->GetWindowState(ev);
  357.  
  358.     ODWindow* odWindow =  windowState->RegisterWindowForFrame(ev, 
  359.                                                         platformWindow, 
  360.                                                         odFrame,
  361.                                                          props.fIsRootWindow,        // Keeps draft open
  362. #ifdef FW_BUILD_MAC
  363.                                                         FALSE,                        // On the Mac we handle the resizing ourself
  364. #else
  365.                                                         props.fIsResizable,            // Is resizable
  366. #endif
  367.                                                          props.fIsFloating,            // Is floating
  368.                                                         TRUE,                        // should save
  369. #ifdef FW_BUILD_MAC
  370.                                                         TRUE,                        // should dispose
  371. #endif    
  372.                                                         props.fSourceFrame);
  373.     
  374.     fWindowID = odWindow->GetID(ev);
  375.     
  376.     FitToScreen(ev);
  377.     
  378.     odWindow->Open(ev);
  379.     if (!hasWinProp)
  380.         odWindow->AdjustWindowShape(ev);
  381.  
  382.     odWindow->Release(ev);
  383. #else
  384.     FW_DEBUG_MESSAGE("Should not be called with this version");
  385. #endif
  386. }
  387.  
  388. #ifdef FW_BUILD_MAC
  389. //---------------------------------------------------------------------------------------
  390. //    FW_CWindow::PrivMacCreatePlatformWindow
  391. //---------------------------------------------------------------------------------------
  392. //    position is the inside position
  393.     
  394. ODPlatformWindow FW_CWindow::PrivMacCreatePlatformWindow(Environment* ev, 
  395.                                                     Str255 windowTitle,
  396.                                                     const FW_CPoint& interiorSize,
  397.                                                     const FW_CPoint& position,
  398.                                                     unsigned short procID,
  399.                                                     FW_Boolean hasCloseBox)
  400. {
  401.     FW_CAcquireCFMResourceAccess qr;
  402.     FW_SPlatformRect windowRect(position.x.AsInt(), position.y.AsInt(), 
  403.                                 position.x.AsInt() + interiorSize.x.AsInt(), 
  404.                                 position.y.AsInt() + interiorSize.y.AsInt());
  405.     
  406.     Handle windowProc = ::GetResource('WDEF', procID >> 4);    // Force load of the resource
  407.     ODPlatformWindow platformWindow = ::NewCWindow(NULL, 
  408.                                                 &windowRect, 
  409.                                                 windowTitle, 
  410.                                                 FALSE, 
  411.                                                 procID,
  412.                                                 (WindowPtr)-1L, 
  413.                                                 hasCloseBox, 
  414.                                                 (long)this);
  415.     
  416.     // Special case with floating windows under system < 7.5
  417.     if ((procID & 0xFFF0) == FW_kNonSystem75WindoidWDEF)
  418.     {
  419.         if (gMacFloatWindowProc == NULL)
  420.         {
  421.             gMacFloatWindowProc = ((WindowPeek)platformWindow)->windowDefProc;
  422.             ::DetachResource(gMacFloatWindowProc);
  423.         }
  424.         else
  425.         {
  426.             Handle temp = ((WindowPeek)platformWindow)->windowDefProc;
  427.             ((WindowPeek)platformWindow)->windowDefProc = gMacFloatWindowProc;
  428.             ::ReleaseResource(temp);
  429.         }
  430.     }
  431.     
  432.     return platformWindow;
  433. }
  434. #endif
  435.  
  436. //---------------------------------------------------------------------------------------
  437. //    FW_CWindow::PrivCreateODWindow
  438. //---------------------------------------------------------------------------------------
  439.  
  440. void FW_CWindow::PrivCreateODWindow(Environment* ev, 
  441.                                         ODPart* thePart,
  442.                                         ODFrame* parentFrame,
  443.                                         FW_Boolean    persistent,
  444.                                         ODTypeToken viewType,
  445.                                         ODTypeToken presentation,
  446.                                         const FW_CString& windowTitle,
  447.                                         const FW_CPoint& interiorSize,
  448.                                         const FW_CPoint& position,
  449.                                         WindowStyle style)
  450. {
  451.     FW_ASSERT(fWindowID == kODNULLID);
  452.     
  453.     ODWindowState* windowState = thePart->GetStorageUnit(ev)->GetSession(ev)->GetWindowState(ev);
  454.  
  455. #ifdef FW_BUILD_MAC    
  456.     unsigned short procID = PrivMacStyleToProcId(ev, style);
  457.     
  458.     Str255 pascalTitle;
  459.     windowTitle.ExportPascal(pascalTitle);
  460.  
  461.     FW_CPoint tempSize(FW_IntToFixed(100), FW_IntToFixed(100));
  462.     FW_CPoint tempPos = tempSize;
  463.     ODPlatformWindow platformWindow = PrivMacCreatePlatformWindow(ev, 
  464.                                                                 pascalTitle, 
  465.                                                                 tempSize, 
  466.                                                                 tempPos, 
  467.                                                                 procID,
  468.                                                                 (FW_kHasCloseBox & style) != 0);    
  469.     
  470.     // Set the right size
  471.     ::SizeWindow(platformWindow, interiorSize.x.AsInt(), interiorSize.y.AsInt(), TRUE);
  472.     
  473.     // because MacCreatePlatformWindow is called with the inside position
  474.     FW_CRect borderSize;
  475.     FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
  476.     ::MoveWindow(platformWindow, 
  477.                 (position.x + borderSize.left).AsInt(), 
  478.                 (position.y + borderSize.top).AsInt(), 
  479.                 FALSE);
  480.     
  481. #endif
  482.  
  483. #ifdef FW_BUILD_WIN
  484.     DWORD windowFlags = PrivWindStyleToWindowsFlags(style);
  485.     
  486.     ODPlatformWindow platformWindow = windowState->CreatePlatformWindow(ev, (style & FW_kFloatingWindow) != 0, windowFlags | WS_CLIPSIBLINGS);
  487.     
  488.     // Associate window pointer with the platform window
  489.     if (platformWindow != NULL)
  490.     {
  491.         ::SetProp(platformWindow, "ODF:Window", (HANDLE) this);
  492.     }
  493. #endif
  494.  
  495.     // ----- Create and return the wrapper window
  496.     ODWindow* odWindow = windowState->RegisterWindow(ev,
  497.                                                     platformWindow, 
  498.                                                     persistent ? kODFrameObject : kODNonPersistentFrameObject,
  499.                                                     (parentFrame == NULL) && ((FW_kFloatingWindow & style) == 0),        // root window
  500. #ifdef FW_BUILD_MAC
  501.                                                     FALSE,        // On the Mac we handle the resizing ourself
  502. #else
  503.                                                     (FW_kResizeable & style) != 0,
  504. #endif
  505.                                                     (FW_kFloatingWindow & style) != 0,
  506.                                                     persistent,        // shouldSave (shouldSave and persistent should always have the same value)
  507. #ifdef FW_BUILD_MAC
  508.                                                     TRUE,                        // should dispose
  509. #endif    
  510.                                                     thePart,
  511.                                                     viewType, 
  512.                                                     presentation,
  513.                                                     parentFrame);
  514.     
  515.     fWindowID = odWindow->GetID(ev);
  516.  
  517.     FitToScreen(ev);
  518.  
  519.     odWindow->Open(ev);
  520.  
  521. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  522.     odWindow->Release(ev);
  523. #endif
  524.  
  525. }
  526.  
  527. //----------------------------------------------------------------------------------------
  528. //    FW_CWindow::GetGraphicDevice
  529. //----------------------------------------------------------------------------------------
  530.  
  531. FW_CGraphicDevice* FW_CWindow::GetGraphicDevice(Environment* ev) const
  532. {
  533.     FW_CWindow* self = (FW_CWindow *)this;
  534.     
  535.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  536.     
  537.     ODFacet* rootFacet = aqODWindow->GetRootFacet(ev);
  538.     FW_CGraphicDevice* device = FW_CFacetPartInfo::GetFacetGraphicDevice(ev, rootFacet);
  539.     
  540.     if (device == NULL)
  541.     {
  542.         if (fGraphicDevice == NULL)        // We never asked for it
  543.         {
  544.             self->fGraphicDevice = new FW_CGraphicDevice(ev, rootFacet->GetCanvas(ev));
  545.         }
  546.         device = fGraphicDevice;
  547.     }    
  548.     
  549.     return device;
  550. }
  551.  
  552. //----------------------------------------------------------------------------------------
  553. //    FW_CWindow::SetWindowSize
  554. //----------------------------------------------------------------------------------------
  555.  
  556. void FW_CWindow::SetWindowSize(Environment* ev, const FW_CPoint& interiorSize)
  557. {    
  558.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  559.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  560.     
  561. #ifdef FW_BUILD_MAC
  562.     ::SizeWindow(platformWindow, interiorSize.x.AsInt(), interiorSize.y.AsInt(), TRUE);
  563. #endif
  564.  
  565. #ifdef FW_BUILD_WIN
  566.     FW_CRect borderSize;
  567.     FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
  568.     
  569.     FW_SPlatformRect windowRect;
  570.     ::GetWindowRect(platformWindow, &windowRect);
  571.  
  572.     int width  = (interiorSize.x + borderSize.left + borderSize.right).AsInt();
  573.     int height = (interiorSize.y + borderSize.top + borderSize.bottom).AsInt();
  574.  
  575.     ::MoveWindow(platformWindow, //::GetParent(platformWindow), 
  576.                 windowRect.left, windowRect.top, 
  577.                 width, height,
  578.                 TRUE);
  579. #endif
  580.     
  581.     // ----- Notify the ODWindow -----
  582.     if (aqODWindow->GetRootFacet(ev) != NULL)
  583.         aqODWindow->AdjustWindowShape(ev);
  584. }
  585.  
  586. //----------------------------------------------------------------------------------------
  587. //    FW_CWindow::SetWindowPosition
  588. //----------------------------------------------------------------------------------------
  589. //    newPosition is the position of the exterior top left corner of the window. This is
  590. //    different from the Mac API where MoveWindow takes the inside top left corner
  591. //    of the window. For once the Windows API makes more sense.
  592.  
  593. void FW_CWindow::SetWindowPosition(Environment* ev, const FW_CPoint& newPosition) 
  594. {
  595.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  596.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  597.     
  598. #ifdef FW_BUILD_MAC
  599.     FW_CRect borderSize;
  600.     FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
  601.     
  602.     ::MoveWindow(platformWindow, (newPosition.x + borderSize.left).AsInt(), (newPosition.y + borderSize.top).AsInt(), FALSE);
  603. #endif
  604.  
  605. #ifdef FW_BUILD_WIN
  606.     FW_SPlatformRect windowRect;
  607.     ::GetWindowRect(platformWindow, &windowRect);
  608.     
  609.     ::MoveWindow(platformWindow,        //::GetParent(platformWindow), 
  610.                 newPosition.x.AsInt(), newPosition.y.AsInt(), 
  611.                 windowRect.right - windowRect.left,
  612.                 windowRect.bottom - windowRect.top,
  613.                 FALSE);
  614. #endif
  615. }
  616.  
  617. //----------------------------------------------------------------------------------------
  618. //    FW_CWindow::WindowToScreen
  619. //----------------------------------------------------------------------------------------
  620.  
  621. void FW_CWindow::WindowToScreen(Environment* ev,
  622.                                 FW_CPoint* points, 
  623.                                 unsigned short nbPoint)
  624. {
  625.     FW_ASSERT(nbPoint > 1);
  626.     
  627. #ifdef FW_BUILD_MAC
  628.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  629.     GrafPtr curPort;
  630.     ::GetPort(&curPort);
  631.     ::SetPort(aqODWindow->GetPlatformWindow(ev));
  632.     
  633.     FW_SPlatformPoint plfmPoint;
  634.     if (nbPoint == 1)
  635.     {
  636.         plfmPoint = *points;
  637.         ::LocalToGlobal(&plfmPoint);
  638.         *points = plfmPoint;
  639.     }
  640.     else
  641.     {
  642.         for (unsigned short i = 0; i<nbPoint; i++)
  643.         {
  644.             plfmPoint = points[i];
  645.             ::LocalToGlobal(&plfmPoint);
  646.             points[i] = plfmPoint;
  647.         }
  648.     }
  649.     
  650.     ::SetPort(curPort);
  651. #endif
  652.  
  653. #ifdef FW_BUILD_WIN
  654.     FW_DEBUG_MESSAGE("Not yet implemented");
  655. #endif
  656. }
  657.  
  658. //----------------------------------------------------------------------------------------
  659. //    FW_CWindow::ScreenToWindow
  660. //----------------------------------------------------------------------------------------
  661.  
  662. void FW_CWindow::ScreenToWindow(Environment* ev,
  663.                                 FW_CPoint* points, 
  664.                                 unsigned short nbPoint)
  665. {
  666.     FW_ASSERT(nbPoint > 1);
  667.     
  668. #ifdef FW_BUILD_MAC
  669.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  670.  
  671.     GrafPtr curPort;
  672.     ::GetPort(&curPort);
  673.     ::SetPort(aqODWindow->GetPlatformWindow(ev));
  674.     
  675.     FW_SPlatformPoint plfmPoint;
  676.     if (nbPoint == 1)
  677.     {
  678.         plfmPoint = *points;
  679.         ::GlobalToLocal(&plfmPoint);
  680.         *points = plfmPoint;
  681.     }
  682.     else
  683.     {
  684.         for (unsigned short i = 0; i<nbPoint; i++)
  685.         {
  686.             plfmPoint = points[i];
  687.             ::GlobalToLocal(&plfmPoint);
  688.             points[i] = plfmPoint;
  689.         }
  690.     }
  691.     
  692.     ::SetPort(curPort);
  693. #endif
  694.  
  695. #ifdef FW_BUILD_WIN
  696.     FW_DEBUG_MESSAGE("Not yet implemented");
  697. #endif
  698. }
  699.  
  700. //----------------------------------------------------------------------------------------
  701. //    FW_CWindow::WindowToScreen
  702. //----------------------------------------------------------------------------------------
  703.  
  704. void FW_CWindow::WindowToScreen(Environment* ev,
  705.                                 FW_CRect& rect)
  706. {
  707.     WindowToScreen(ev, (FW_CPoint*)&rect, 2);
  708. }
  709.  
  710. //----------------------------------------------------------------------------------------
  711. //    FW_CWindow::ScreenToWindow
  712. //----------------------------------------------------------------------------------------
  713.  
  714. void FW_CWindow::ScreenToWindow(Environment* ev,
  715.                                 FW_CRect& rect)
  716. {
  717.     ScreenToWindow(ev, (FW_CPoint*)&rect, 2);
  718. }
  719.  
  720. //----------------------------------------------------------------------------------------
  721. // FW_PrivFitRect
  722. //----------------------------------------------------------------------------------------
  723. //    return:
  724. //        0: nothing changed
  725. //        1: position changed
  726. //        2: size changed
  727. //        3: position and size changed
  728.  
  729. static short FW_PrivFitRect(const FW_CRect& containingRect, FW_CRect& rect)
  730. {
  731.     short changed = 0;
  732.     
  733.     // ----- Be sure that it fits on the screen -----
  734.     if (rect.left < containingRect.left)
  735.     {
  736.         changed |= 0x0001;
  737.         rect.Offset(containingRect.left - rect.left, FW_kFixed0);
  738.     }
  739.  
  740.     if (rect.top < containingRect.top)
  741.     {
  742.         changed |= 0x0001;
  743.         rect.Offset(FW_kFixed0, containingRect.top - rect.top);
  744.     }
  745.  
  746.     if (rect.right > containingRect.right)
  747.     {
  748.         changed |= 0x0001;
  749.         rect.Offset(containingRect.right - rect.right, FW_kFixed0);
  750.         if (rect.left < containingRect.left)
  751.         {
  752.             changed |= 0x0002;
  753.             rect.left = containingRect.left;
  754.         }
  755.     }
  756.     
  757.     if (rect.bottom > containingRect.bottom)
  758.     {
  759.         changed |= 0x0001;
  760.         rect.Offset(FW_kFixed0, containingRect.bottom - rect.bottom);
  761.         if (rect.top < containingRect.top)
  762.         {
  763.             changed |= 0x0002;
  764.             rect.top = containingRect.top;
  765.         }
  766.     }
  767.     
  768.     return changed;
  769. }
  770.  
  771. //----------------------------------------------------------------------------------------
  772. // FW_CWindow::FitToScreen
  773. //----------------------------------------------------------------------------------------
  774.  
  775. void FW_CWindow::FitToScreen(Environment* ev)
  776. {
  777.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  778.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  779.     
  780.     FW_CRect border;
  781.     FW_CWindow::PrivGetBorderSize(platformWindow, border);
  782.  
  783. #ifdef FW_BUILD_MAC
  784.     FW_CRect screenRect;
  785.     ::FW_MacGetMaxIntersectedDevice(platformWindow, screenRect);
  786.     screenRect.Inset(FW_IntToFixed(3), FW_IntToFixed(3));    // leave space around window structure area
  787. #endif
  788.  
  789. #ifdef FW_BUILD_WIN
  790.     FW_SPlatformRect plScreenRect;
  791.     ::GetWindowRect(::GetDesktopWindow(), &plScreenRect);
  792.     FW_CRect screenRect(plScreenRect);
  793. #endif
  794.  
  795. #ifdef FW_BUILD_MAC
  796.     FW_CPoint windowPos, windowSize;
  797.     
  798.     GetWindowPosition(ev, windowPos);
  799.     GetWindowSize(ev, windowSize);
  800.     FW_CRect windowRect(windowPos.x,
  801.                         windowPos.y,
  802.                         windowPos.x + windowSize.x + border.left + border.right,
  803.                         windowPos.y + windowSize.y + border.top + border.bottom);
  804. #endif
  805.  
  806. #ifdef FW_BUILD_WIN
  807.     FW_SPlatformRect plWindowRect;
  808.     ::GetWindowRect(platformWindow, &plWindowRect);
  809.     FW_CRect windowRect(plWindowRect);
  810. #endif
  811.     
  812.     short changed = FW_PrivFitRect(screenRect, windowRect);
  813.         
  814.     if ((changed & 0xFFFE) != 0)
  815.         SetWindowPosition(ev, windowRect.TopLeft());
  816.     
  817.     if ((changed & 0xFFFD) != 0)
  818.     {
  819.         FW_CPoint windowSize(windowRect.Width() - border.left - border.right, 
  820.                              windowRect.Height() - border.top - border.bottom);
  821.         SetWindowSize(ev, windowSize);
  822.     }
  823. }
  824.  
  825. //----------------------------------------------------------------------------------------
  826. //    FW_CWindow::GetWindowSize
  827. //----------------------------------------------------------------------------------------
  828. // Returns the inside size of the window
  829.  
  830. void FW_CWindow::GetWindowSize(Environment* ev, FW_CPoint& interiorSize) const
  831. {
  832.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  833.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  834.  
  835. #ifdef FW_BUILD_MAC
  836.     interiorSize.x = FW_IntToFixed(platformWindow->portRect.right - platformWindow->portRect.left);
  837.     interiorSize.y = FW_IntToFixed(platformWindow->portRect.bottom - platformWindow->portRect.top);
  838. #endif
  839.  
  840. #ifdef FW_BUILD_WIN
  841.     FW_SPlatformRect windowRect;
  842.     ::GetWindowRect(platformWindow, &windowRect);
  843.  
  844.     FW_CRect borderSize;
  845.     FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
  846.     
  847.     interiorSize.x = FW_IntToFixed(windowRect.right - windowRect.left) - borderSize.left - borderSize.right;
  848.     interiorSize.y = FW_IntToFixed(windowRect.bottom - windowRect.top) - borderSize.top - borderSize.bottom;
  849. #endif    
  850. }
  851.  
  852. //----------------------------------------------------------------------------------------
  853. //    FW_CWindow::GetWindowPosition
  854. //----------------------------------------------------------------------------------------
  855. // Returns the outside position of the window
  856.  
  857. void FW_CWindow::GetWindowPosition(Environment* ev, FW_CPoint& position) const
  858. {
  859.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  860.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  861.  
  862. #ifdef FW_BUILD_MAC
  863.     GrafPtr curPort;
  864.     ::GetPort(&curPort);
  865.     ::SetPort(platformWindow);
  866.     Point localToGlobal = {platformWindow->portRect.top, platformWindow->portRect.left};
  867.     ::LocalToGlobal(&localToGlobal);
  868.     ::SetPort(curPort);
  869.     
  870.     FW_CRect borderSize;
  871.     FW_CWindow::PrivGetBorderSize(platformWindow, borderSize);
  872.  
  873.     position.x = FW_IntToFixed(localToGlobal.h) - borderSize.left;
  874.     position.y = FW_IntToFixed(localToGlobal.v) - borderSize.top;
  875. #endif
  876.  
  877. #ifdef FW_BUILD_WIN
  878.     FW_SPlatformRect windowRect;
  879.     ::GetWindowRect(platformWindow, &windowRect);
  880.     
  881.     position.x = FW_IntToFixed(windowRect.left);
  882.     position.y = FW_IntToFixed(windowRect.top);
  883. #endif
  884. }
  885.  
  886. //----------------------------------------------------------------------------------------
  887. //    FW_CWindow::PrivGetBorderSize
  888. //----------------------------------------------------------------------------------------
  889. //    Returns the size of the border in pixels
  890.  
  891. void FW_CWindow::PrivGetBorderSize(ODPlatformWindow platformWindow, FW_CRect &borderSize)
  892. {
  893.     FW_ASSERT(platformWindow != NULL);
  894.     
  895. #ifdef FW_BUILD_MAC
  896.     WindowRecord *windowRec = (WindowRecord*)platformWindow;
  897.  
  898.     FW_Boolean rgnsWereBuilt = FW_MacBuildWindowRegions(platformWindow, TRUE);
  899.     FW_SPlatformRect outside = (*windowRec->strucRgn)->rgnBBox;
  900.     FW_SPlatformRect inside = (*windowRec->contRgn)->rgnBBox;
  901.     FW_MacBuildWindowRegions(platformWindow, rgnsWereBuilt);
  902. #endif
  903.  
  904. #ifdef FW_BUILD_WIN
  905.     DWORD dwStyle = (DWORD)::GetWindowLong(platformWindow, GWL_STYLE);
  906.     DWORD dwExStyle = (dwStyle & DS_MODALFRAME) ? WS_EX_DLGMODALFRAME : 0L;
  907.     
  908.     FW_SPlatformRect inside;
  909.     ::GetClientRect(platformWindow, &inside);
  910.  
  911.     FW_SPlatformRect outside(inside.left, inside.top, inside.right, inside.bottom);
  912.     
  913.     ::AdjustWindowRectEx(&outside, dwStyle ^ DS_MODALFRAME, FALSE, dwExStyle);
  914. #endif
  915.  
  916.     borderSize.left = FW_IntToFixed(inside.left - outside.left);
  917.     borderSize.top = FW_IntToFixed(inside.top - outside.top);
  918.     borderSize.right = FW_IntToFixed(outside.right - inside.right);
  919.     borderSize.bottom = FW_IntToFixed(outside.bottom - inside.bottom);
  920. }
  921.  
  922. //----------------------------------------------------------------------------------------
  923. // FW_CWindow::IsFloating
  924. //----------------------------------------------------------------------------------------
  925.  
  926. FW_Boolean FW_CWindow::IsFloating(Environment* ev) const
  927. {
  928.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  929.     return aqODWindow->IsFloating(ev);
  930. }
  931.  
  932. //----------------------------------------------------------------------------------------
  933. // FW_CWindow::IsActive
  934. //----------------------------------------------------------------------------------------
  935.  
  936. FW_Boolean FW_CWindow::IsActive(Environment* ev) const
  937. {
  938.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  939.     return aqODWindow->IsActive(ev);
  940. }
  941.  
  942. //----------------------------------------------------------------------------------------
  943. // FW_CWindow::GetPlatformWindow
  944. //----------------------------------------------------------------------------------------
  945.  
  946. ODPlatformWindow FW_CWindow::GetPlatformWindow(Environment* ev) const
  947. {
  948.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  949.     return aqODWindow->GetPlatformWindow(ev);
  950. }
  951.  
  952. //----------------------------------------------------------------------------------------
  953. //    FW_CWindow::GetBorderSize
  954. //----------------------------------------------------------------------------------------
  955.  
  956. void FW_CWindow::GetBorderSize(Environment* ev, FW_CRect &borderSize) const
  957. {
  958.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  959.     FW_CWindow::PrivGetBorderSize(aqODWindow->GetPlatformWindow(ev), borderSize);
  960. }
  961.  
  962. //----------------------------------------------------------------------------------------
  963. //    FW_CWindow::Close
  964. //----------------------------------------------------------------------------------------
  965.  
  966. void FW_CWindow::Close(Environment* ev)
  967. {
  968.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  969.     aqODWindow->Close(ev);
  970. }
  971.  
  972. //----------------------------------------------------------------------------------------
  973. //    FW_CWindow::Close
  974. //----------------------------------------------------------------------------------------
  975.  
  976. void FW_CWindow::CloseAndRemove(Environment* ev)
  977. {
  978.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  979.     aqODWindow->CloseAndRemove(ev);
  980. }
  981.  
  982. //----------------------------------------------------------------------------------------
  983. //    FW_CWindow::Select
  984. //----------------------------------------------------------------------------------------
  985.  
  986. void FW_CWindow::Select(Environment* ev) const
  987. {
  988.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  989.     aqODWindow->Select(ev);
  990. }
  991.  
  992. //----------------------------------------------------------------------------------------
  993. //    FW_CWindow::IsShown
  994. //----------------------------------------------------------------------------------------
  995.  
  996. FW_Boolean FW_CWindow::IsShown(Environment* ev) const
  997. {
  998.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  999.     return aqODWindow->IsShown(ev);
  1000. }
  1001.  
  1002. //----------------------------------------------------------------------------------------
  1003. // FW_CWindow::Hide
  1004. //----------------------------------------------------------------------------------------
  1005.  
  1006. void FW_CWindow::Hide(Environment* ev)
  1007. {
  1008.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  1009.     aqODWindow->Hide(ev);
  1010. }
  1011.  
  1012. #ifdef FW_BUILD_MAC
  1013. //----------------------------------------------------------------------------------------
  1014. //    FW_CWindow::PrivMacTrackResizeWindow
  1015. //----------------------------------------------------------------------------------------
  1016.  
  1017.  void FW_CWindow::PrivMacTrackResizeWindow(Environment* ev, const FW_CRect& growLimits, const FW_CMacWindowEvent& windowEvent)
  1018.  {    
  1019.      ODEventData* eventData = ((FW_CMacWindowEvent&)windowEvent).GetPlatformEvent();
  1020.      
  1021.      FW_SPlatformRect plfmGrowLimits;
  1022.      growLimits.AsPlatformRect(plfmGrowLimits);
  1023.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  1024.     long newWindowSize = ::GrowWindow(aqODWindow->GetPlatformWindow(ev), eventData->where, &plfmGrowLimits);
  1025.     
  1026.     FW_CPoint interiorSize(FW_IntToFixed(LoWord(newWindowSize)), FW_IntToFixed(HiWord(newWindowSize)));    
  1027.     this->SetWindowSize(ev, interiorSize);
  1028. }
  1029. #endif
  1030.  
  1031. #ifdef FW_BUILD_MAC
  1032. //----------------------------------------------------------------------------------------
  1033. //    FW_CWindow::PrivMacDoZoom
  1034. //----------------------------------------------------------------------------------------
  1035.  
  1036. void FW_CWindow::PrivMacDoZoom(Environment* ev, 
  1037.                             const FW_CPoint& zoomedSize, 
  1038.                             const FW_CRect& borderSize,
  1039.                             const FW_CRect& screenRect,
  1040.                             unsigned long message)
  1041. {
  1042.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  1043.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  1044.  
  1045.     if (message == inZoomOut)
  1046.     {
  1047.         // ----- Calculate the outside bounds of the window -----
  1048.         FW_CPoint windowPos;
  1049.         GetWindowPosition(ev, windowPos);
  1050.         
  1051.         FW_CRect windowRect(windowPos.x, 
  1052.                             windowPos.y,
  1053.                             windowPos.x + zoomedSize.x + borderSize.left + borderSize.right,
  1054.                             windowPos.y + zoomedSize.y + borderSize.top + borderSize.bottom);
  1055.         
  1056.         // ----- Be sure that it fits on the screen -----
  1057.         FW_PrivFitRect(screenRect, windowRect);
  1058.         
  1059.         // ----- Calculate the inside -----
  1060.         windowRect.left += borderSize.left;
  1061.         windowRect.right -= borderSize.right;
  1062.         windowRect.top += borderSize.top;
  1063.         windowRect.bottom -= borderSize.bottom;
  1064.         
  1065.         // ----- and set the stdState -----
  1066.         windowRect.AsPlatformRect((*((WStateDataHandle)(((WindowPeek)platformWindow)->dataHandle)))->stdState);
  1067.     }
  1068.  
  1069.     ::FW_MacZoomWindow(platformWindow, message == inZoomIn);
  1070.     
  1071.     aqODWindow->AdjustWindowShape(ev);
  1072. }
  1073. #endif
  1074.  
  1075. #ifdef FW_BUILD_MAC
  1076. //----------------------------------------------------------------------------------------
  1077. //    FW_CWindow::PrivMacStyleToProcId
  1078. //----------------------------------------------------------------------------------------
  1079.  
  1080. unsigned short FW_CWindow::PrivMacStyleToProcId(Environment *ev, WindowStyle windowStyle)
  1081. {
  1082.     unsigned short procId;
  1083.     
  1084.     if (windowStyle & FW_kStandardWindow)
  1085.     {
  1086.         if (windowStyle & FW_kResizeable)
  1087.             if (windowStyle & FW_kHasMaximizeBox)
  1088.                 procId = zoomDocProc;
  1089.             else
  1090.                 procId = documentProc;
  1091.         else if (windowStyle & FW_kHasMaximizeBox)
  1092.             procId = zoomNoGrow;
  1093.         else
  1094.             procId = noGrowDocProc;
  1095.     }
  1096.     else if (windowStyle & FW_kModelessDialog)
  1097.     {
  1098.         procId = documentProc;
  1099.     }
  1100.     else if (windowStyle & FW_kModalDialog)
  1101.     {
  1102.         if (windowStyle & FW_kHasCaption)
  1103.             procId = movableDBoxProc;
  1104.         else
  1105.             procId = dBoxProc;
  1106.  
  1107.     }
  1108.     else if (windowStyle & FW_kFloatingWindow)
  1109.     {
  1110.         // Check first if we have the system 7.5 resource
  1111.         Handle hld = ::GetResource('WDEF', 124);
  1112.         if (hld == NULL)
  1113.             procId = FW_kNonSystem75WindoidWDEF;
  1114.         else
  1115.             procId = FW_kSystem75WindoidWDEF;
  1116.  
  1117.         if (windowStyle & FW_kHasMaximizeBox)
  1118.             procId += FW_kSystem75HasZoom;
  1119.         if (windowStyle & FW_kResizeable)
  1120.             procId += FW_kSystem75HasGrow;
  1121.     }
  1122. //    else if (windowStyle & FW_kMacDesktopPane)
  1123. //    {
  1124. //        procId = plainDBox;
  1125. //    }
  1126.     else
  1127.     {
  1128.         FW_ASSERT(FALSE);
  1129.         procId = documentProc;
  1130.     }
  1131.     
  1132.     return procId;
  1133. }
  1134. #endif
  1135.  
  1136. #ifdef FW_BUILD_WIN
  1137. //----------------------------------------------------------------------------------------
  1138. //    FW_CWindow::PrivWindStyleToWindowsFlags
  1139. //----------------------------------------------------------------------------------------
  1140.  
  1141. DWORD FW_CWindow::PrivWindStyleToWindowsFlags(WindowStyle style)
  1142. {
  1143.     DWORD dwStyle = 0;
  1144.  
  1145.     if (style & FW_kStandardWindow)
  1146.         dwStyle |= WS_CHILD;
  1147.     else if (style & FW_kOverlappedWindow)
  1148.         dwStyle |= WS_OVERLAPPED;
  1149.     else if (style & FW_kFloatingWindow)
  1150.         dwStyle |= /*WS_POPUP |*/ WS_CAPTION;
  1151.     else if (style & FW_kModelessDialog)
  1152.         dwStyle |= (WS_POPUP | DS_MODALFRAME);
  1153.     else if (style & FW_kModalDialog)
  1154.         dwStyle |= (WS_POPUP | DS_MODALFRAME);// DS_MODALFRAME will be transform into WS_EX_DLGMODALFRAME
  1155.     else
  1156.         FW_ASSERT(FALSE);
  1157.         
  1158.     if (style & FW_kResizeable)
  1159.         dwStyle |= WS_THICKFRAME;
  1160.  
  1161.     if (style & FW_kHasCaption)
  1162.         dwStyle |= WS_CAPTION;
  1163.  
  1164.     if (style & FW_kHasCloseBox)
  1165.         dwStyle |= WS_SYSMENU;
  1166.  
  1167.     if (style & FW_kHasMinimizeBox)
  1168.         dwStyle |= WS_MINIMIZEBOX;
  1169.  
  1170.     if (style & FW_kHasMaximizeBox)
  1171.         dwStyle |= WS_MAXIMIZEBOX;
  1172.  
  1173.     return dwStyle;
  1174. }
  1175. #endif
  1176.  
  1177. #ifdef FW_BUILD_WIN
  1178. //----------------------------------------------------------------------------------------
  1179. // FW_CWindow::PrivWindFixSystemMenu
  1180. //----------------------------------------------------------------------------------------
  1181. //    Makes system menu consistent with platform dialogs
  1182.  
  1183. void FW_CWindow::PrivWindFixSystemMenu(WindowStyle windowStyle)
  1184. {
  1185. #if 0
  1186.     // Make system menu standard for windows dialogs
  1187.     HMENU fMenuHandle = ::GetSystemMenu(GetPlatformWindow(), FALSE);
  1188.  
  1189.     if (fMenuHandle != NULL)
  1190.     {
  1191.         BR_CBedrock* bedrock = BR_CBedrock::GetBedrock();
  1192.         BR_CCharString255 MenuText;
  1193.         
  1194.         // Delete all items
  1195.         while (::DeleteMenu(fMenuHandle, 0, MF_BYPOSITION))
  1196.             ;
  1197.  
  1198.         // Flags for ::AppendMenu()
  1199.         const WORD wfItemFlags = MF_BYCOMMAND | MF_ENABLED | MF_STRING;
  1200.  
  1201.         // Add in dialog menu
  1202.         if (windowStyle & (kHasMinimizeBox | FW_kHasMaximizeBox))
  1203.         {
  1204.             bedrock->LoadString(IDSL_SYSTEMMENU, IDS_RESTORE, MenuText);
  1205.             ::AppendMenu(fMenuHandle, wfItemFlags, SC_RESTORE, MenuText);
  1206.         }
  1207.  
  1208.  
  1209.         {
  1210.             bedrock->LoadString(IDSL_SYSTEMMENU, IDS_MOVE, MenuText);
  1211.             ::AppendMenu(fMenuHandle, wfItemFlags, SC_MOVE, MenuText);
  1212.         }
  1213.  
  1214.         if (windowStyle & FW_kResizeable)
  1215.         {
  1216.             bedrock->LoadString(IDSL_SYSTEMMENU, IDS_SIZE, MenuText);
  1217.             ::AppendMenu(fMenuHandle, wfItemFlags, SC_SIZE, MenuText);
  1218.         }
  1219.  
  1220.         if (windowStyle & FW_kHasMinimizeBox)
  1221.         {
  1222.             bedrock->LoadString(IDSL_SYSTEMMENU, IDS_MINIMIZE, MenuText);
  1223.             ::AppendMenu(fMenuHandle, wfItemFlags, SC_MINIMIZE, MenuText);
  1224.         }
  1225.  
  1226.         if (windowStyle & FW_kHasMaximizeBox)
  1227.         {
  1228.             bedrock->LoadString(IDSL_SYSTEMMENU, IDS_MAXIMIZE, MenuText);
  1229.             ::AppendMenu(fMenuHandle, wfItemFlags, SC_MAXIMIZE, MenuText);
  1230.         }
  1231.  
  1232.         ::AppendMenu(fMenuHandle, MF_SEPARATOR, 0, NULL);
  1233.  
  1234.         {
  1235.             bedrock->LoadString(IDSL_SYSTEMMENU, IDS_CLOSE, MenuText);
  1236.             ::AppendMenu(fMenuHandle, wfItemFlags, SC_CLOSE, MenuText);
  1237.         }
  1238.     }
  1239. #endif
  1240. }
  1241. #endif
  1242.